package models

import (
	"common/node_pieces"
	"common/uuid"
)

const (
	StatusNormal = 0
	StatusRepair = 1
)

type Segment struct {
	ID         int64                  `gorm:"column:id;notNull;primaryKey;comment:id" json:"id"`
	StreamId   uuid.UUID              `gorm:"column:stream_id;type:BINARY(16);notNull;index:seg_idx;comment:流id" json:"stream_id"`
	Position   int                    `gorm:"column:position;type:smallint;index:seg_idx;comment:segment位置" json:"position"`
	PieceNum   uint8                  `gorm:"column:piece_num;notNull;default:0;comment:分片数量" json:"piece_num""`
	PlainSize  int64                  `gorm:"column:plain_size;notNull;default:0;comment:源大小" json:"plain_size"`
	NodePieces node_pieces.NodePieces `gorm:"column:node_pieces;type:bytes;size:850;comment:节点片的印射表,最多分50个节点" json:"node_pieces"`
	Pad        int                    `gorm:"column:pad;type:tinyint" json:"pad"`
	Folded     bool                   `gorm:"column:folded;notNull;default:false;comment:是否有重叠的数据节点" json:"folded"`
	Status     int8                   `gorm:"column:status;notNull;default:0;comment:1则在修复中" json:"status"`
}
